package com.summer.data.jql.concept.alias;

import com.summer.data.Jsql;
import com.summer.data.dialect.Dialect;
import com.summer.data.jql.Context;
import com.summer.data.jql.behavior.GroupAble;
import com.summer.data.jql.behavior.SelectAble;
import com.summer.data.jql.concept.Field;

/**
 * @author 345480567@qq.com
 */
public class FieldAlias implements SelectAble, GroupAble {

    private Field field;

    private String aliasName;

    public FieldAlias(Field field, String aliasName) {
        this.field = field;
        this.aliasName = aliasName;
    }

    @Override
    public Jsql toSelectJsql(Context ctx, Dialect dialect) {
        return Jsql.format("%s %s", field.toSelectJsql(ctx, dialect), aliasName);
    }

    // todo:
    @Override
    public Jsql toGroupSql(Context ctx, Dialect dialect) {
        return null;
    }

}

